import os
import json
class Config(object):
    # 默认的地址，不一样的就建立个database.json
    host="192.168.50.4"
    user="root"
    password="123"
    database="job"    
    if os.path.exists("database.json"):
        # print("读取database.json.连接数据库...")
        with open("database.json") as f:
            data = json.loads(f.read())
            print(data)
            host = data['host']
            user = data['user']
            password=data['password']
            database=data['database']
    # 数据库连接地址
    SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://{}:{}@{}:3306/{}?charset=utf8'.format(user,password,host,database)
    SQLALCHEMY_TRACK_MODIFICATIONS = True
    # ENV是development时会自动开启。这里默认开启
    DEBUG=True
    # 打印sql语句
    SQLALCHEMY_ECHO=True

config = Config()